﻿

using ETModel;

namespace ETHotfix {
    /// <summary>
    /// "HotfixInit"为(固定的)热更层初始化事件名
    /// </summary>
    [Event(EventIdType.HotfixInit)]
    public class HotfixInit : AEvent {
        public override void Run() {


            // 加载配置
            ETModel.Game.Scene.GetComponent<ResourcesComponent>().LoadBundle("config.unity3d");
            Game.Scene.AddComponent<ConfigComponent, string>("config.unity3d|Config");
            ETModel.Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle("config.unity3d");

            UnitConfig unitConfig = Game.Scene.GetComponent<ConfigComponent>().Get<UnitConfig>(1002);
            Log.Debug($"测试获取一个单位配置 Id:{unitConfig.Id} {JsonHelper.ToJson(unitConfig)} ");

            Game.Scene.AddComponent<PlayersComponent>();

            Log.Debug("Demo完成热更层的初始化操作,触发进入大厅事件");
            Game.EventSystem.Run(HotfixEventIdType.EnterLobby);

        }
    }
}
